1. Field of the Invention
This invention generally relates to software execution of processes and, more particularly, to a system and method for accurately determining processor idle time on a periodic basis.
2. Description of the Related Art
A computer processor or microprocessor is “idle” when it is not executing instructions from a program or software application. Some low priority software programs are designed to be executed by a processor's central processing unit (CPU), so as to not impact programs which run at a normal priority. Programs that use CPU idle time cause the CPU to always be 100% utilized, so that the time spent where the CPU would have been idle is instead spent performing useful computations.
Most operating systems (OSs) display an idle task, which is a special task loaded by the OS scheduler only when there is nothing for the computer to do. The idle task can be hard-coded into the scheduler, or it can be implemented as a separate software application with the lowest possible priority. One advantage of using the idle task is that it can be monitored, to give an indication of processor usage. Windows NT's System Idle Process is an example.
In Windows NT operating systems, the System Idle Process is a kernel thread that runs when no other runnable thread can be scheduled on a CPU. For example, there may be no runnable thread in the system, or all runnable threads are already running on a different CPU. The System Idle Process is used by Windows NT to implement CPU power saving. The exact power saving scheme depends on the hardware and firmware capabilities of the system in question. For instance, with x86 processors, the process will run a loop of halt (HLP) instructions, which causes the CPU to turn off many internal components (saving power) and wait until an interrupt request (IRQ) arrives. On modern processors, where a HLT instruction saves significant amounts of power and heat, the idle task almost always consists of a loop which repeatedly executes HLT instructions.
The CPU time consumed by the System Idle Process is commonly of interest for end users, as it is a measure of the CPU utilization in their system, which is easily accessible through Windows' Task Manage program. There are, however, more detailed sources of such information available through Windows' performance monitoring system (accessible with the perfmon program), which includes more finely grained categorization of CPU time spending. A limited subset of the CPU time categorization is also accessible through the Task Manager, which can display CPU usage, categorized by time spent in user vs. kernel code. It should be noted, though, that that information is not calculated from information about the System Idle Process, but from the system's global performance counters.
When no other application is using the CPU processing power, the System Idle Process takes these CPU cycles. If the “CPU Time” column in Windows Task Manager is enabled, it can be seen that there is a continuous count—a measure of how long the computer has been switched on in the current session.
Thus, idle tasks are certainly not novel. They report the idle time of the processor given a particular time period. The problem is that the time period is not flexible. For example, in the context of a microprocessor-based printer, a print pipeline has several stages that must be undertaken before a print job can be successfully processed. The following is an example.                Host connects to the printer.        The printer makes a connection from the network application to the printer description language (PDL).        Intermediate buffers are filled.        The PDL starts to interpret the job.        As the PDL produces pages, each page needs to be rendered.        The rendered results need to be sent to the engine.        
With this example, the prior art would represent the idle time for the entire print operation. An idle time report of 30% is meaningless for a programmer seeking to optimize a software program, because a simple percentage does not isolate where the idle time occurs in the print process. As a result, it is impossible to determine where optimization is required.
It would be advantageous if an idle task monitor existed that permitted idle time reports to be based upon periodic intervals, such as an idle time percentage per second.
It would be advantageous if the periodic idle time reporting could also be merged with milestones in the program to make optimization easier.